package com.chuangke.mds.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.chuangke.common.db.page.CkPageQuery;
import com.chuangke.common.http.HttpResult;
import com.chuangke.mds.entity.MaterialAttributeConf;
import com.chuangke.mds.service.MaterialAttributeConfService;

/**
 * @author panyingzu
 * @title MaterialConfController
 * @description
 * @Date 2025/3/1 20:51
 */
@RestController
@RequestMapping("zchkcl/materialConf")
public class MaterialConfController {

    @Autowired
    private MaterialAttributeConfService materialAttributeConfService;

    @PreAuthorize("hasAuthority('login:action')")
    @PostMapping(value = "/save")
    public HttpResult save(@RequestBody MaterialAttributeConf record) {
        return HttpResult.ok(materialAttributeConfService.saveOrUpdate(record));
    }


    @PreAuthorize("hasAuthority('login:action')")
    @PostMapping(value = "/delete")
    public HttpResult delete(@RequestBody List<String> billIds) {
        materialAttributeConfService.delete(billIds);
        return HttpResult.ok();
    }

    @PreAuthorize("hasAuthority('login:action')")
    @PostMapping("/page")
    public HttpResult page(@RequestBody Map<String, Object> params) {
        return HttpResult.ok(materialAttributeConfService.page(new CkPageQuery(params)));
    }


    @PreAuthorize("hasAuthority('login:action')")
    @GetMapping("/load")
    public HttpResult load(@RequestParam String id) {
        return HttpResult.ok(materialAttributeConfService.load(id));
    }


}
